package com.ucar.umock.client.exector;

import com.ucar.umock.client.dto.UMockMethodRuntimeInfoDTO;
import com.ucar.umock.client.config.UMockMethodConfigBean;
import com.ucar.umock.client.enums.EnumMockExectorType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName UMockValueExectorComposite
 * @Description TODO
 * @Author zhanbs baoshan.zhan@ucarinc.com
 * @Date 2020/4/3 10:57
 * @Version 1.0
 **/
@Slf4j
@Component
public class UMockValueExectorComposite {


    @Autowired
    private List<UMockValueExector> umockValueHandles;


    public Object exec(UMockMethodConfigBean config, UMockMethodRuntimeInfoDTO methodRuntimeDTO){
        EnumMockExectorType handleType=config.getHandleType();
        for(UMockValueExector handle :umockValueHandles){
            if(handle.getType()==handleType){
                return handle.exec(config,methodRuntimeDTO);
            }
        }
        return null;
    }

}
